﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Drawing;

namespace Vit.Report.XmlWebReport
{
    public class DivReportRenderer : IReportRender
    {
        #region IReportRender Members

        public void RenderCell(TextWriter writer, Page page, RectanglePosition pos, RectangleF rect, string id, string innerContent, string cssClass, string style, int zIndex, Font font)
        {
            writer.WriteLine(@"<div id=""{0}"" class=""{1}"" style=""width:{3}{2};height:{4}{2};top:{5}{2};left:{6}{2};position:absolute;z-index:{7};{8}line-height:{9};"">",
                id, cssClass, page.Unit, rect.Width, rect.Height, rect.Y, rect.X, zIndex, ReportHelper.ToHtmlFont(font), pos.LineHeight);

            innerContent = ReportHelper.ResolveToHtml(innerContent);
            writer.WriteLine(@"<div id=""{0}_content""{1}{2}>", id,
                string.IsNullOrEmpty(style) ? "" : string.Format(" style='{0}'", style),
                pos.Editable ? " contenteditable='true'" : "");
            writer.WriteLine(innerContent);
            writer.WriteLine("</div>");

            writer.WriteLine("</div>");
        }

        public void RenderPage(TextWriter writer, Page page)
        {
        }

        #endregion
    }
}
